package com.atguigu.springcloud.service.impl;

import cn.hutool.core.thread.ThreadUtil;
import com.atguigu.springcloud.dao.AccountDao;
import com.atguigu.springcloud.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @PROJECT_NAME: cloud2020
 * @DESCRIPTION:
 * @Author: csc
 * @DATE: 2023/4/6 14:47
 */
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;

    @Override
    public void decrease(Long userId, BigDecimal money) {
        log.info("--->AccountServiceImpl 本地 扣除账户余额开始--");
        //扣减账户余额
        ThreadUtil.sleep(20*1000);
        accountDao.decrease(userId,money);
        log.info("--->AccountServiceImpl 本地 扣除账户余额结束--");
    }//end

}
